import { fromJS } from 'immutable'
import { actionTypes } from '../store'

const defaultState= fromJS({
    topicList:[],
    articleList:[],
    Recommend:[],
    Writer:[],
    WriterPage:1,
    WriterTotalPage:1
});

export default  (state = defaultState,action)=>{
    switch (action.type){
        case actionTypes.CHANGE_HOME_INFO:
                return state.merge({
                    topicList:fromJS(action.value.topicList),
                    articleList:fromJS(action.value.articleList),
                    Recommend:fromJS(action.value.Recommend),
                    Writer:fromJS(action.value.Writer),
                    WriterTotalPage:fromJS(action.totalPage)
                  });
          case actionTypes.ADD_LIST:
                  let articleList=state.get('articleList');
                  let moreArticleList=articleList.concat(fromJS(action.value.articleList));
                  return state.set('articleList',moreArticleList);
          case actionTypes.GET_AUTHOR:

                  return state.set('WriterPage',action.value);
          default:
                  return state;
    }  
}